<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Person() {
            this.eyes = 2;
            this.head = 1;
            this.sayHi = function () {
                console.log('Hi');
            }
        };
        function Woman() {
            this.baby = function () {
                console.log('宝贝');
            };
        };
        function Man() {

        };
        console.log(new Person());
        // 利用原型对象添加公共的属性和方法
        Woman.prototype = new Person();
        // 手动将原型对象指向构造函数
        Woman.prototype.constructor = Woman;
        const red = new Woman();
        console.log(red);
        console.log(red.eyes);

        Man.prototype = new Person();
        Man.prototype.constructor = Man;
        const pink = new Man();
        console.log(pink);
        console.log(pink.eyes);
        console.log(pink.sayHi());
    </script>
</body>

</html>